home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmigaPlus / Tools / Development / MCC_TheBar / Developer / C / Examples / demo3.c < prev    next >
Encoding:
C/C++ Source or Header  |  2004-01-31  |  11.4 KB  |  282 lines

  1.  
  2. #include <proto/exec.h>
  3. #include <proto/dos.h>
  4. #include <proto/muimaster.h>
  5. #include <clib/alib_protos.h>
  6. #include <mui/TheBar_mcc.h>
  7. #include <string.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10.  
  11. /***********************************************************************/
  12.  
  13. long __stack = 8192;
  14. struct Library *MUIMasterBase;
  15.  
  16. /***********************************************************************/
  17.  
  18. #ifndef MAKE_ID
  19. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  20. #endif
  21.  
  22. /***********************************************************************/
  23.  
  24. STRPTR pics[] =
  25. {
  26.     "Add",
  27.     "Clone",
  28.     "Edit",
  29.     "Remove",
  30.     "Search",
  31.     "Prefs",
  32.     "Login",
  33.     NULL
  34. };
  35.  
  36. STRPTR spics[] =
  37. {
  38.     "Add_S",
  39.     "Clone_S",
  40.     "Edit_S",
  41.     "Remove_S",
  42.     "Search_S",
  43.     "Prefs_S",
  44.     "Login_S",
  45.     NULL
  46. };
  47.  
  48. STRPTR dpics[] =
  49. {
  50.     "Add_G",
  51.     "Clone_G",
  52.     "Edit_G",
  53.     "Remove_G",
  54.     "Search_G",
  55.     "Prefs_G",
  56.     "Login_G",
  57.     NULL
  58. };
  59.  
  60. struct MUIS_TheBar_Button buttons[] =
  61. {
  62.     {0,     0, "_Get", "Get the disc."},
  63.     {1,     1, "Sa_ve", "Save the disc."},
  64.     {2,     2, "_Stop", "Stop the connection."},
  65.     {MUIV_TheBar_BarSpacer,-1},
  66.     {3,     3, "_Disc", "Disc page."},
  67.     {MUIV_TheBar_ButtonSpacer,-1},
  68.     {0,     4, "_Stop2", "Stop2 the connection."},
  69.     {4,     5, "_Matches", "Matches page.", MUIV_TheBar_ButtonFlag_Immediate|MUIV_TheBar_ButtonFlag_Selected, 1<<6},
  70.     {MUIV_TheBar_ImageSpacer,-1},
  71.     {5,     6, "_Edit", "Edit page.", MUIV_TheBar_ButtonFlag_Immediate, 1<<5},
  72.     {MUIV_TheBar_End},
  73. };
  74.  
  75. char *rowss[]       = {"0","1","2","3","6",NULL};
  76. char *colss[]       = {"0","1","2","3","4","5","6",NULL};
  77. char *viewModes[]   = {"Images and text","Images","Text",NULL};
  78. char *buttonsPoss[] = {"Left","Center","Right",NULL};
  79. char *labelPoss[]   = {"Bottom","Top","Right","Left",NULL};
  80.  
  81. int
  82. main(int argc,char **argv)
  83. {
  84.     int res;
  85.  
  86.     if (MUIMasterBase = OpenLibrary("muimaster.library",19))
  87.     {
  88.         Object *app, *win, *mg, *sb, *viewMode, *buttonsPos, *labelPos, *borderless, *sunny,
  89.                *raised, *scaled, *keys, *bspacer, *fixed, *free, *update, *rows, *cols, *s4, *h0,
  90.                *rb, *rs, *ri;
  91.  
  92.         if (app = ApplicationObject,
  93.                 MUIA_Application_Title,        "TheBar Demo3",
  94.                 MUIA_Application_Version,      "$VER: TheBarDemo3 1.0 (24.6.2003)",
  95.                 MUIA_Application_Copyright,    "Copyright 2003 by Alfonso Ranieri",
  96.                 MUIA_Application_Author,       "Alfonso Ranieri <alforan@tin.it>",
  97.                 MUIA_Application_Description,  "TheBar example",
  98.                 MUIA_Application_Base,         "THEBAREXAMPLE",
  99.  
  100.                 SubWindow, win = WindowObject,
  101.                     MUIA_Window_ID,    MAKE_ID('M','A','I','N'),
  102.                     MUIA_Window_Title, "TheBar Demo3",
  103.  
  104.                     WindowContents, mg = VGroup,
  105.  
  106.                         Child, sb = TheBarObject,
  107.                             MUIA_Group_Horiz,        TRUE,
  108.                             MUIA_TheBar_ViewMode,    MUIV_TheBar_ViewMode_Gfx,
  109.                             MUIA_TheBar_Buttons,     buttons,
  110.                             MUIA_TheBar_PicsDrawer,  "PROGDIR:Pics",
  111.                             MUIA_TheBar_Pics,        pics,
  112.                             MUIA_TheBar_SelPics,     spics,
  113.                             MUIA_TheBar_DisPics,     dpics,
  114.                         End,
  115.  
  116.                         Child, VGroup,
  117.                             GroupFrameT("Appareance"),
  118.                             Child, ColGroup(2),
  119.                                 Child, Label2("Rows"),
  120.                                 Child, HGroup,
  121.                                     Child, rows = MUI_MakeObject(MUIO_Radio,NULL,rowss),
  122.                                     Child, HSpace(0),
  123.                                 End,
  124.                                 Child, Label2("Columns"),
  125.                                 Child, HGroup,
  126.                                     Child, cols = MUI_MakeObject(MUIO_Radio,NULL,colss),
  127.                                     Child, HSpace(0),
  128.                                 End,
  129.                                 Child, Label2("ViewMode"),
  130.                                 Child, viewMode = MUI_MakeObject(MUIO_Cycle,NULL,viewModes),
  131.                                 Child, Label2("Buttons position"),
  132.                                 Child, buttonsPos = MUI_MakeObject(MUIO_Cycle,NULL,buttonsPoss),
  133.                                 Child, Label2("Label position"),
  134.                                 Child, labelPos = MUI_MakeObject(MUIO_Cycle,NULL,labelPoss),
  135.                             End,
  136.                             Child, ScrollgroupObject,
  137.                                 MUIA_Scrollgroup_FreeHoriz, FALSE,
  138.                                 MUIA_Scrollgroup_Contents, VirtgroupObject,
  139.                                     MUIA_Frame, MUIV_Frame_Virtual,
  140.                                     Child, HGroup,
  141.                                         Child, ColGroup(2),
  142.                                             Child, borderless = MUI_MakeObject(MUIO_Checkmark,NULL),
  143.                                             Child, LLabel1("Borderless"),
  144.                                             Child, sunny = MUI_MakeObject(MUIO_Checkmark,NULL),
  145.                                             Child, LLabel1("Sunny"),
  146.                                             Child, raised = MUI_MakeObject(MUIO_Checkmark,NULL),
  147.                                             Child, LLabel1("Raised"),
  148.                                             Child, scaled = MUI_MakeObject(MUIO_Checkmark,NULL),
  149.                                             Child, LLabel1("Scaled"),
  150.                                             Child, keys = MUI_MakeObject(MUIO_Checkmark,NULL),
  151.                                             Child, LLabel1("Enable keys"),
  152.                                             Child, bspacer = MUI_MakeObject(MUIO_Checkmark,NULL),
  153.                                             Child, LLabel1("Bar spacer"),
  154.                                             Child, fixed = MUI_MakeObject(MUIO_Checkmark,NULL),
  155.                                             Child, LLabel("Fixed"),
  156.                                             Child, free = MUI_MakeObject(MUIO_Checkmark,NULL),
  157.                                             Child, LLabel("Disable 0"),
  158.                                             Child, h0 = MUI_MakeObject(MUIO_Checkmark,NULL),
  159.                                             Child, LLabel("Hide 0"),
  160.                                             Child, s4 = MUI_MakeObject(MUIO_Checkmark,NULL),
  161.                                             Child, LLabel("Sleep 4"),
  162.                                             Child, RectangleObject, MUIA_FixHeightTxt,"a",End,
  163.                                             Child, RectangleObject, MUIA_FixHeightTxt,"a",End,
  164.                                             Child, rb = MUI_MakeObject(MUIO_Checkmark,NULL),
  165.                                             Child, LLabel("Remove Bars"),
  166.                                             Child, rs = MUI_MakeObject(MUIO_Checkmark,NULL),
  167.                                             Child, LLabel("Remove Spaces"),
  168.                                             Child, ri = MUI_MakeObject(MUIO_Checkmark,NULL),
  169.                                             Child, LLabel("Remove Images"),
  170.                                         End,
  171.                                         Child, HSpace(0),
  172.                                     End,
  173.                                     Child, VSpace(0),
  174.                                 End,
  175.                             End,
  176.                             Child, update = MUI_MakeObject(MUIO_Button,"_Update"),
  177.                         End,
  178.                     End,
  179.                 End,
  180.             End)
  181.         {
  182.             ULONG sigs = 0, id;
  183.  
  184.             set(rows,MUIA_Group_Horiz,TRUE);
  185.             set(cols,MUIA_Group_Horiz,TRUE);
  186.             set(viewMode,MUIA_Cycle_Active,1);
  187.             set(s4,MUIA_Selected,TRUE);
  188.  
  189.             DoMethod(win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,MUIV_Notify_Application,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  190.             DoMethod(update,MUIM_Notify,MUIA_Pressed,FALSE,app,2,MUIM_Application_ReturnID,TAG_USER);
  191.  
  192.             set(win,MUIA_Window_Open,TRUE);
  193.  
  194.             while ((id = DoMethod(app,MUIM_Application_NewInput,&sigs))!=MUIV_Application_ReturnID_Quit)
  195.             {
  196.                 if (id==TAG_USER)
  197.                 {
  198.                     ULONG c, r, vm, bp, lp, br, su, ra, sc, k, bs, fi, fr, hl0, sl4, rbl, rsl, ril, rem;
  199.  
  200.                     get(rows,MUIA_Radio_Active,&r);
  201.                     if (r==4) r = 6;
  202.                     get(cols,MUIA_Radio_Active,&c);
  203.  
  204.                     get(viewMode,MUIA_Cycle_Active,&vm);
  205.                     get(buttonsPos,MUIA_Cycle_Active,&bp);
  206.                     get(labelPos,MUIA_Cycle_Active,&lp);
  207.  
  208.                     get(borderless,MUIA_Selected,&br);
  209.                     get(sunny,MUIA_Selected,&su);
  210.                     get(raised,MUIA_Selected,&ra);
  211.                     get(scaled,MUIA_Selected,&sc);
  212.                     get(keys,MUIA_Selected,&k);
  213.                     get(bspacer,MUIA_Selected,&bs);
  214.                     get(fixed,MUIA_Selected,&fi);
  215.                     get(free,MUIA_Selected,&fr);
  216.  
  217.                     get(h0,MUIA_Selected,&hl0);
  218.                     get(s4,MUIA_Selected,&sl4);
  219.  
  220.                     get(rb,MUIA_Selected,&rbl);
  221.                     get(rs,MUIA_Selected,&rsl);
  222.                     get(ri,MUIA_Selected,&ril);
  223.                     rem = 0;
  224.                     if (rbl) rem |= MUIV_TheBar_Remove_BarSpacers;
  225.                     if (rsl) rem |= MUIV_TheBar_Remove_ButtonSpacers;
  226.                     if (ril) rem |= MUIV_TheBar_Remove_ImageSpacers;
  227.  
  228.                     DoMethod(mg,MUIM_Group_InitChange);
  229.                     DoMethod(sb,MUIM_Group_InitChange);
  230.  
  231.                     SetAttrs(sb,MUIA_TheBar_Columns,      c,
  232.                                 MUIA_TheBar_Rows,         r,
  233.                                 MUIA_TheBar_ViewMode,     vm,
  234.                                 MUIA_TheBar_Borderless,   br,
  235.                                 MUIA_TheBar_Sunny,        su,
  236.                                 MUIA_TheBar_Raised,       ra,
  237.                                 MUIA_TheBar_Scaled,       sc,
  238.                                 MUIA_TheBar_EnableKeys,   k,
  239.                                 MUIA_TheBar_BarSpacer,    bs,
  240.                                 MUIA_TheBar_Remove,       rem,
  241.                                 MUIA_TheBar_LabelPos,     lp,
  242.                                 TAG_DONE);
  243.  
  244.                     DoMethod(sb,MUIM_TheBar_SetAttr,0,MUIV_TheBar_Attr_Hide,hl0);
  245.                     DoMethod(sb,MUIM_TheBar_SetAttr,4,MUIV_TheBar_Attr_Sleep,sl4);
  246.  
  247.                     DoMethod(sb,MUIM_TheBar_SetAttr,6,MUIV_TheBar_Attr_Disabled,fr);
  248.  
  249.                     DoMethod(sb,MUIM_Group_ExitChange);
  250.                     DoMethod(mg,MUIM_Group_ExitChange);
  251.                 }
  252.  
  253.                 if (sigs)
  254.                 {
  255.                     sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  256.                     if (sigs & SIGBREAKF_CTRL_C) break;
  257.                 }
  258.             }
  259.  
  260.             MUI_DisposeObject(app);
  261.  
  262.             res = RETURN_OK;
  263.         }
  264.         else
  265.         {
  266.             printf("%s: can't create application\n",argv[0]);
  267.             res = RETURN_FAIL;
  268.         }
  269.  
  270.         CloseLibrary(MUIMasterBase);
  271.     }
  272.     else
  273.     {
  274.         printf("%s: Can't open muimaster.library ver 19 or higher\n",argv[0]);
  275.         res = RETURN_ERROR;
  276.     }
  277.  
  278.     return res;
  279. }
  280.  
  281. /***********************************************************************/
  282.